package com.brainardphotography.blog.utils;

import static java.lang.System.out;

public class BlogUtils {
	public static final String ILLEGAL_ID_CHARS = "[^a-z0-9\\-\\_]";
	
	public static String createIdFromTitle(String title) {
		return title.trim()
				.replaceAll(" ", "-")
				.toLowerCase()
				.replaceAll(ILLEGAL_ID_CHARS, "");
	}
	
	public static void main(String[] args) {
		String[] titles = new String[] {
				"Welcome to my blog!",
				"   Welcome to my blog!*()*!)!   "
		};
		
		for(String title : titles) {
			out.println(createIdFromTitle(title));
		}
	}
}
